<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<style>

    .umpires{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        height: 40px;
        margin-bottom: 10px;
    }
    .umpires span{
        margin-right: 20px;
        cursor:pointer;
        font-size: 14px;
    }
    .unactive{
        border-bottom: 2px solid #0d78fc;
        font-size: 16px;
    }

</style>
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">

<!--<div th:text="${examinationResultsComDO}"></div>-->
                        <div class="umpires"></div>
                        <div id="box"></div>

<!--                        <input type="hidden" name="id" >-->
<!--                        <input type="hidden" name="type" >-->

<!--                        -->

<!--                        <div class="form-group">-->
<!--                            <label class="col-sm-3 control-label">裁判B：</label>-->
<!--                            <div class="col-sm-8">-->
<!--                                <input name="score2" class="form-control" type="text" >-->
<!--                            </div>-->
<!--                        </div>-->

<!--                        <div class="form-group">-->
<!--                            <label class="col-sm-3 control-label">裁判C：</label>-->
<!--                            <div class="col-sm-8">-->
<!--                                <input name="score3" class="form-control" type="text" >-->
<!--                            </div>-->
<!--                        </div>-->

                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="button" onclick="update()" class="btn btn-primary">提交</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script src="//s.xlongwei.com/res/js/My97DatePicker/WdatePicker.js"></script>
<script>



    function UrlSearch(){
        var name,value;
        var str=location.href; //取得整个地址栏
        var num=str.indexOf("?")
        str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]

        var arr=str.split("&"); //各个参数放到数组里
        for(var i=0;i < arr.length;i++){
            num=arr[i].indexOf("=");
            if(num>0){
                name=arr[i].substring(0,num);
                value=arr[i].substr(num+1);
                this[name]=value;
            }
        }
    }

    let Request = new UrlSearch();
    $.ajax({
        cache : true,
        type : "get",
        url : "/jzweb/markA/selEditData",
        data : {
            competition: 'A',
            cbatchId: Request.cbatchId,
            signId: Request.signId,
            ebatchId: Request.ebatchId
        },// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            if (data.code == 0) {
                let str = '' , srr = '';
                let datas = data.data;
                datas?.map(function (v){
                    console.log(datas)
                    v.markVO?.map(function (val,k){
                        str += `
                        <div class="form-group boxList" style="${k == 0 ? 'dipslay:block':'display:none'}">
                            <label class="col-sm-3 control-label">${val.username}：</label>
                            <div class="col-sm-8">
                                <input name="score1" class="form-control score" type="text" data-makid="${val.makId}" value="${val.score}">
                            </div>
                        </div>`;

                        srr+=`<span class="${k == 0? 'unactive':''}" data-index="${k}">${val.username}</span>`;

                    })
                })

                $("#box").html(str)
                $(".umpires").html(srr)

                $(".umpires").find('span').click(function (){
                    $(".umpires").find('span').removeClass('unactive');
                    $(this).addClass('unactive');
                    $(".boxList").hide();
                    $(".boxList").eq($(this).index()).show();
                })

            } else {
                parent.layer.alert(data.msg)
            }

        }
    });


    function update() {
        let params = {};
        $(".boxList").eq($('.unactive').attr('data-index')).each(function (k,v){
            params.updateScore = $(v).find('.score').val();
            params.makId = $(v).find('.score').attr('data-makid');
        })

        $.ajax({
            cache : true,
            type : "POST",
            url : "/jzweb/markA/conservatorJudgeMark",
            data : JSON.stringify(params),// 你的formid
            async : false,
            contentType: 'application/json',
            error : function(request) {
                parent.layer.alert("Connection error");
            },
            success : function(data) {
                if (data.code == 0) {
                    parent.layer.msg("操作成功");
                    parent.reLoad();
                    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                    parent.layer.close(index);

                } else {
                    parent.layer.alert(data.msg)
                }

            }
        });

    }

</script>
</body>
</html>
